home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.awt;
-
- import java.awt.image.ImageProducer;
- import java.io.BufferedInputStream;
- import java.io.InputStream;
- import java.net.MalformedURLException;
- import java.net.URL;
- import sun.awt.image.GifImageDecoder;
- import sun.awt.image.ImageDecoder;
- import sun.awt.image.JPEGImageDecoder;
- import sun.awt.image.URLImageSource;
-
- public class StreamImageSource extends URLImageSource implements ImageProducer {
- InputStream stream;
- int type;
- URL base;
- static URL baseUrl;
- public static final int GIF = 0;
- public static final int JPEG = 1;
-
- public StreamImageSource(InputStream var1, int var2) {
- this(baseUrl, var1, var2);
- }
-
- public StreamImageSource(URL var1, InputStream var2, int var3) {
- super(var1);
- if (var3 != 0 && var3 != 1) {
- throw new IllegalArgumentException("Unsupported image type:" + var3);
- } else {
- this.stream = var2;
- this.type = var3;
- }
- }
-
- public static void setBaseUrl(URL var0) {
- baseUrl = var0;
- }
-
- public static URL getBaseUrl() {
- return baseUrl;
- }
-
- protected ImageDecoder getDecoder() {
- BufferedInputStream var1 = new BufferedInputStream(this.stream);
- switch (this.type) {
- case 0:
- return new GifImageDecoder(this, var1);
- case 1:
- return new JPEGImageDecoder(this, var1);
- default:
- throw new IllegalArgumentException("Unsupported image type:" + this.type);
- }
- }
-
- static {
- try {
- baseUrl = new URL("file://");
- } catch (MalformedURLException var0) {
- }
- }
- }
-